/*
 * Copyright (C) 2020-present, kinbug All rights reserved.
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.gitee.kinbug.sniper.web.websocket.config;

import java.util.concurrent.ConcurrentHashMap;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.HandlerMapping;
import org.springframework.web.reactive.socket.server.support.WebSocketHandlerAdapter;

import com.gitee.kinbug.sniper.web.websocket.annotations.WebSocketMappingHandlerMapping;
import com.gitee.kinbug.sniper.web.websocket.entity.WebSocketSender;

/**
 * -WebSocket配置文件
 * @ClassName: WebSocketConfig
 * @author kinbug
 * @date 2020年9月14日
 */
@Configuration
public class WebSocketConfig {

	@Bean
	public HandlerMapping webSocketMapping() {
		return new WebSocketMappingHandlerMapping();
	}

	@Bean
	public ConcurrentHashMap<String, WebSocketSender> senderMap() {
		return new ConcurrentHashMap<String, WebSocketSender>(1024);
	}

	@Bean
	public WebSocketHandlerAdapter handlerAdapter() {
		return new WebSocketHandlerAdapter();
	}
}
